1) { foreach($sep_tags as $value){ if ($value != "") { array_push($itemarray,trim(utf8_encode($value))); } } // } }; $depth[$parser]++; } //**************************************************************************************************************** function characterData($parser, $data) { } //**************************************************************************************************************** function endElement($parser, $name) { global $depth, $currentTag, $currentAttribs, $itemarray ; $depth[$parser]--; } //**************************************************************************************************************** function processalbum($file,$folpath) { global $depth,$itemcounts,$albumpath,$array_album,$itemarray,$debug; $albumpath = $folpath ; $depth = array(); $fp = "";$data =""; if (isset($itemarray)) { reset($itemarray); unset($itemarray); } global $itemarray; $itemarray = array(); $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); if (!($fp = fopen($file, "r"))) { die("could not open XML input"); } while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } $array_album .= implode(",", $itemarray); $array_album .= ","; if ($debug == "Y") { echo "
filename: ".$folpath."
Value:".$array_album."


"; }; fclose($fp); xml_parser_free($xml_parser); } //processalbum function ends here //**************************************************************************************************************** function read_text($filename) { $lines = file($filename); foreach ($lines as $line_num => $line) { echo $line."
"; } } //**************************************************************************************************************** function display_results() { global $array_album,$tagsfile,$debug; $array_expl = explode(",",$array_album); //without sorting and uniuque if ($debug == "Y" ) { echo "content=Before sorting and removing unique
"; foreach($array_expl as $value){ echo $value."
"; } } //after sorting and uniuque $array_final= array_unique($array_expl); sort($array_final); //write to tagslist file $file = fopen($tagsfile, "w+") or die("Can't open text file for writing"); $writetext = "\xEF\xBB\xBF". "content="; echo "content="; if ($debug == "Y" ) { echo "content=after sorting and removing duplicates
"; } foreach($array_final as $value){ if ($value != "") { $writetext = $writetext .utf8_decode($value). "||"; echo utf8_decode($value)."||"; } } fwrite($file, $writetext); } //**************************************************************************************************************** if ($albumpath == "" ) { $xmlpath = "photos.xml"; if (file_exists($xmlpath)) { processalbum($xmlpath,$albumpath); } map_dirs("."); display_results(); } function map_dirs($path) { if(is_dir($path)) { if($contents = opendir($path)) { while(($node = readdir($contents)) !== false) { if( (!strpos($node,".")) && $node!="res" && $node !="images" && $node != "slides" && $node !="thumbs" && $node !="rss_styles" && $node!= "." && $node!= ".." ) { if ($path==".") { $folpath = $node."/"; if (file_exists($folpath."photos.xml")) { processalbum($folpath."photos.xml",$folpath); } } else { $folpath = $path."/".$node."/"; $folpath = ltrim($folpath,'./'); if (file_exists($folpath."photos.xml")) { processalbum($folpath."photos.xml",$folpath); } } map_dirs("$path/$node"); } } } } } ?>